<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #cart {
            width: 300px;
            margin: 0 auto;
        }

        #cart h3 {
            border: 1px solid gray;
        }

        dl,
        dt,
        dd {
            border: 1px solid gray;
        }
        /* dl{
           position: relative;
           top:-20px;
        } */
        .show {
            display: block;
        }

        .hide {
            display: none;
        }

        #xxx {
            color: red;
            font-size: 50px;
        }
    </style>
</head>

<body>



    <div id="cart">
        <h3  id="mycart"><img src="../img/java.png" width="30px" height="30px" alt="">我的购物出</h3>
        <dl id="mycartInfo" class="hide">
            <dt>最新加入商品</dt>
            <dd>
                <img src="../img/java.png" width="50px" height="50px" alt="">
                xxx润肤液
            </dd>
            <dd>
                <img src="../img/java.png" width="50px" height="50px" alt="">
                家电
            </dd>
            <dd>
                <img src="../img/java.png" width="50px" height="50px" alt="">
                家电
            </dd>
        </dl>
    </div>
    <script>
        // function show() {
        //     document.getElementById("mycartInfo").className = 'show'
        // }
        // function hide() {
        //     document.getElementById("mycartInfo").className = 'hide'
        // }
        document.getElementById("mycart").addEventListener("mouseenter", function () {
            // alert('enter')
            document.getElementById("mycartInfo").className = 'show'

        })
        document.getElementById("mycart").addEventListener("mouseout", function () {
            // alert('leave')
            document.getElementById("mycartInfo").className = 'hide'
        })
        //1.通过style修改样式
        // document.getElementById("xxx").style.color="blue";
        // document.getElementById("xxx").style.fontSize="50px";
        //2.通过className修改
        // document.getElementById("xxx").className = 'xxx';
    </script>
</body>

</html>